#include <regx52.h>
#include "Delay.h"

sbit SER = P3^4; //SER
sbit RCK = P3^5; //RCLK
sbit SCK = P3^6; //SRCLK

const unsigned char Animation[] = {
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0xFF,0x08,0x08,0x08,0xFF,0x00,0x0E,0x15,
	0x15,0x15,0x0C,0x00,0xFE,0x01,0x02,0x00,
	0xFE,0x01,0x02,0x00,0x0E,0x11,0x11,0x11,
	0x0E,0x00,0x00,0x3D,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00
	};

/**
  * @brief  74HC595数据写入
  * @param  Data：要写入的数据，8位，高位在上
  * @retval 无
  */

void _74HC595_WriteData(unsigned char Data)
{
	unsigned char i = 0;
	for( i = 0; i < 8; i++ )
	{
		SER = Data & (0x80 >> i);
		SCK = 1;
		SCK = 0;
	}
	RCK = 1;
	RCK = 0;
}

/**
  * @brief  矩阵键盘显示一列数据
  * @param  Data：要显示的数据，8位，高位在上，1为亮
  * @param	Column：要显示的列，取值范围：0~7，0是最左边
  * @retval 无
  */

void MatrixLED_ShowColumn(unsigned char Data,Column)
{
	_74HC595_WriteData(Data);
	P0 = ~(0x80>>Column);
	Delay(1);	//消影
	P0 = 0xff;
}

/**
  * @brief  74HC595初始化
  * @param  无
  * @retval 无
  */

void _74HC595_Init(void)
{
	SCK = 0;
	RCK = 0;
}

/**
  * @brief  点阵屏初始化
  * @param  无
  * @retval 无
  */

void MatrixLED_Init(void)
{
	_74HC595_Init();
}
